package com.iqik.change.service.impl;

import com.iqik.change.mapper.UserMapper;
import com.iqik.change.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    private UserMapper userMapper;

    @Autowired(required = false)
    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public String getUserById(int id) {
        return userMapper.getUserById(id).toString();
    }

    @Override
    public List<String> getUsers() {
        List<String> list = new ArrayList<>();
        userMapper.getUsers().forEach(user -> list.add(user.toString()));
        return list;
    }
}
